package cn.school.handler;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RoInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(request.getSession().getAttribute("USER_LOGIN")==null){
            request.setAttribute("msg","您么有登录,不能访问["+request.getServletPath()+"]");
            request.getRequestDispatcher("/userLogin.jsp").forward(request,response);
            return false;
        }
        return true;
    }
}
